<?php
class UserAction extends Action{
	public function index(){
		$m=M('User');
		$arr=$m->select();
		$this->assign('data',$arr);
		$this->display();
	}
	public function del(){
		$m=M('User');
		$count=$m-delete($_GET['id']);
		if($count>0){
			$this->success('数据删除成功');
		}else{
			$this->error('数据删除失败');
		}
	}
	public function modify(){
		$id=$_GET['id'];
		$m=M('User');
		$arr=$m->find($id);
		$this->assign('data',$arr);
		$this->display();
	}
	public function update(){
		$m=M('User');
		$data['id']=$_POST['id'];
		$data['name']=$_POST['name'];
		$data['password']=$_POST['password'];
		$count=$m->save($data);
		if($count>0){
			$this->success('数据修改成功','index');
		}else{
			$this->error('数据修改失败');
		}
	}
	public function add(){
		$this->display();
	}
	public function create(){
		$m=M('User');
		$m->name=$_POST['name'];
		$m->password=$_POST['password'];
		$count=$m->add();
		if($count>0){
			$this->success('数据添加成功','index');
		}else{
			$this->error('数据修改失败');
		}
	}
	public function search(){
		$m=M('User');
		$where['name']=array('like',"%{$_POST['name']}%");
		$arr=$m->where($where)->select();
		$this->assign('data',$arr);
		$this->display('index');
	}
}


?>